package create.single;

/**
 * @author lzp
 * @Date:2023/2/24
 * @description: 静态内部类的写法 ， 实现延时加载，singleton2被加载时没有实例化对象，只有singletonHolder被加载调用时才实例化
 */
public class Singleton2 {

	private Singleton2() {

	}

	/**
	 * 静态内部类 ，主类对内部类有所有访问权限
	 */
	private static class SingletonHolder {
		private static final Singleton2 INSTANCE = new Singleton2();
	}

	public static final Singleton2 getInstance() {
		return SingletonHolder.INSTANCE;
	}


}
